package com.restkeeper.vo.store;

/**
 * @ClassName: PageVO
 * @description: TODO
 * @author: 有罗敷的马同学
 * @datetime: 2023Year-05Month-20Day-15:16
 * @Version: 1.0
 */

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
public class PageVO<T> {

    private long counts; //总个数

    private long pagesize; //每页个数

    private long pages; //总页数

    private long page; //当前页

    private List<T> items; //数据记录

    public PageVO(IPage page) {
        this.pagesize = page.getSize();
        this.counts = page.getTotal();
        this.page = page.getCurrent();
        this.pages = page.getPages();
        this.items = page.getRecords();
    }

    //支持自定义列表
    public PageVO(IPage page, List<T> items) {
        this.pagesize = page.getSize();
        this.counts = page.getTotal();
        this.page = page.getCurrent();
        this.pages = page.getPages();
        this.items = items;
    }
}